if (CC_PREVIEW) {

    (function () {
        var RewardedVideoAd = function () {
            this.onCloseCallbacks = [];
            this.load = function () {
                var r = confirm('广告是否加载成功');
                return r ? Promise.resolve() : Promise.reject();
            }
            this.show = function () {
                var r = confirm('广告是否显示成功');
                if (r) {
                    setTimeout(function () {
                        var r1 = confirm('广告是否观看完成');
                        for (var i = 0; i < this.onCloseCallbacks.length; i++) {
                            this.onCloseCallbacks[i] && this.onCloseCallbacks[i]({ isEnded: r1 });
                        }
                    }.bind(this), 200);
                }
                return r ? Promise.resolve() : Promise.reject();
            }
            this.destroy = function () { }
            this.onLoad = function () { }
            this.offLoad = function (callback) { }
            this.onError = function (callback) { }
            this.offError = function (callback) { }
            this.onClose = function (callback) {
                this.onCloseCallbacks.push(callback);
            }
            this.offClose = function (callback) {
                delete this.onCloseCallbacks[callback];
            }
        }
        var rv = {};
        var zz = {};
        zz.createRewardedVideoAd = function (object) {
            if (rv[object.adUnitId]) {
                return rv[object.adUnitId];
            }
            var ad = new RewardedVideoAd();
            rv[object.adUnitId] = ad;
            return ad;
        }
        window.RewardedVideoAd = RewardedVideoAd;
        window.zz = zz;
    })();
}
